Passed
Pull Request — master (#35)
by Pieter Epeüs
01:41
created

f   A

Complexity

Total Complexity 19

Size/Duplication

Total Lines 1
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 19
eloc 1
dl 0
loc 1
rs 10
c 0
b 0
f 0
1
class t{constructor(t,r){this.key=t,this.moveDirection="desc"===r?-1:1}order(t){return t.sort(this.compare.bind(this))}compare(t,r){let e=t[this.key],n=r[this.key];return"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof n&&(n=n.toUpperCase()),e<n?-1*this.moveDirection:e>n?1*this.moveDirection:0}static create(r,e,n){return new t(e,n).order(r)}}function r(r,e,n){return t.create(r,e,n)}function e(t){return"object"!=typeof t||t.length<1?null:t.reduce((t,r)=>Math.min(t,r))}function n(t){return"object"!=typeof t||t.length<1?null:t.reduce((t,r)=>Math.max(t,r))}class i{constructor(t,r){this.find=t,this.operator=r||null}check(t){return Array.isArray(this.find)?this.checkOperators(t,this.find.indexOf(t)<0):this.checkOperators(t,String(t)!==String(this.find))}checkOperators(t,r){const i=n(this.find),s=e(this.find),h=null!==i,o=null!==s;return r&&("!="===this.operator||"<>"===this.operator)||!r&&!this.operator||(t>i&&h||t>this.find)&&">"===this.operator||(t>=i&&h||t>=this.find)&&">="===this.operator||(t<s&&o||t<this.find)&&"<"===this.operator||(t<=s&&o||t<=this.find)&&"<="===this.operator}static create(t,r,e,n){const s=new i(e,n);return t.filter(t=>{let e=t[r];return!!e&&(e=e.toString().split(","),e.some(s.check.bind(s)))})}}function s(t,r,e,n){return i.create(t,r,e,n)}function h(t,r){return t.map(t=>{const e={};return"object"==typeof r?(r.forEach(r=>{e[r]=t[r]}),e):t[r]})}function o(t,r,e){return t.filter(t=>e?r.reduce((r,e)=>e.indexOf(t)>=0?r+1:r,0)===r.length:r.indexOf(t)>=0)}class u{constructor(t,r,e){this.currentArray=t,this.otherArray=r,this.total=e}get differenceArray(){return this.currentArray.filter(t=>this.otherArray.indexOf(t)<0)}get differenceArrayB(){return this.total?this.otherArray.filter(t=>this.currentArray.indexOf(t)<0):[]}get compare(){return this.differenceArray.concat(this.differenceArrayB)}static create(t,r,e){return new u(t,r,e).compare}}function c(t,r,e){return u.create(t,r,e)}function a(t){return t.filter((t,r,e)=>e.indexOf(t)===r)}function l(t){return!Array.isArray(t)||t.length<1?null:t.reduce((t,r)=>t+r,0)}function f(t){return!Array.isArray(t)||t.length<1?null:l(t)/t.length}function p(t){const r=t.length;return t[Math.floor(Math.random()*(r-0))+0]}function y(t,r,e){const n=r.split(".");let i=t;for(;n.length>0;){const t=n.shift();if(null==i||!Object.prototype.hasOwnProperty.call(i,t))return e;i=i[t]}return i}function d(t){return!Array.isArray(t)||t.length<1?null:t[0]}function g(t){return!Array.isArray(t)||t.length<1?null:t[t.length-1]}class A extends Array{static get[Symbol.species](){return Array}multisort(t,e){return r(this[0],t,e)}multifilter(t,r,e){return s(this[0],t,r,e)}multikey(t){return h(this[0],t)}intersect(t,r){return o(this[0],t,r)}diff(t,r){return c(this[0],t,r)}get unique(){return a(this[0])}pushIfNotExists(t){return this.indexOf(t)<0&&this.push(t),this.length}pushMultiple(t){return this.push(...t),this.length}pushMultipleIfNotExists(t){const r=this;return t.forEach(t=>{r.pushIfNotExists(t)}),r.length}get max(){return n(this[0])}get min(){return e(this[0])}get random(){return p(this)}get summ(){return l(this[0])}get average(){return f(this[0])}getByKey(t,r){return y(this[0],t,r)}get first(){return d(this[0])}get last(){return g(this[0])}}export{A as Arr,f as average,c as diff,d as first,y as getByKey,o as intersect,g as last,n as max,e as min,s as multifilter,h as multikey,r as multisort,p as random,l as summ,a as unique};
0 ignored issues
show
introduced by
File has too many classes (4). Maximum allowed is 1.
Loading history...
introduced by
't' is already declared in the upper scope.
Loading history...
introduced by
'r' is already declared in the upper scope.
Loading history...
introduced by
Expected an assignment or function call and instead saw an expression.
Loading history...
introduced by
Unexpected use of comma operator.
Loading history...
introduced by
Expected literal to be on the right side of ===.
Loading history...
introduced by
Expected blank line between class members.
Loading history...
Coding Style introduced by
As per coding-style, please split let declaration into multiple statements.
Loading history...
introduced by
'e' is already declared in the upper scope.
Loading history...
introduced by
'n' is already declared in the upper scope.
Loading history...
introduced by
Expected literal to be on the right side of ==.
Loading history...
Bug Best Practice introduced by
Apart from some edge-cases, it is generally advisable to use the strict comparison === instead of ==.

The loose comparison such as == or != might produce some weird results for some values, unless you explicitly want to have this behavior here, better use the strict alternative.

Learn more about loose comparison in Javascript.

Loading history...
introduced by
Do not nest ternary expressions.
Loading history...
introduced by
A constructor name should not start with a lowercase letter.
Loading history...
introduced by
Expected literal to be on the right side of !=.
Loading history...
Bug Best Practice introduced by
Apart from some edge-cases, it is generally advisable to use the strict comparison !== instead of !=.

The loose comparison such as == or != might produce some weird results for some values, unless you explicitly want to have this behavior here, better use the strict alternative.

Learn more about loose comparison in Javascript.

Loading history...
Coding Style introduced by
As per coding-style, please split const declaration into multiple statements.
Loading history...
introduced by
'i' is already declared in the upper scope.
Loading history...
introduced by
's' is already declared in the upper scope.
Loading history...
introduced by
'h' is already declared in the upper scope.
Loading history...
introduced by
Expected literal to be on the right side of !==.
Loading history...
introduced by
'o' is already declared in the upper scope.
Loading history...
introduced by
Return statement should not contain assignment.
Loading history...
Coding Style introduced by
This line has a length of 3419. Maximum allowed is 120.
Loading history...
2
//# sourceMappingURL=helpers.modern.js.map
0 ignored issues
show
introduced by
Expected exception block, space or tab after '//' in comment.
Loading history...
3